package com.wenwan.manage.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wenwan.manage.mapper.ArticleExamineAdoptMapper;
import com.wenwan.manage.service.ArticleExamineAdoptService;
import com.wenwan.manage.setting.RegExpSetting;
import com.wenwan.manage.setting.StatusSetting;
import com.wenwan.manage.util.Util;

@Service
public class ArticleExamineAdoptServiceImpl implements ArticleExamineAdoptService {

	@Autowired
	private ArticleExamineAdoptMapper articleExamineAdoptMapper;

	@Override
	public Map<String, Object> create(String articleExamineId) {
		// TODO Auto-generated method stub
		// DataToObject<Boolean> dto = new DataToObject<Boolean>();
		Map<String, Object> dto = new HashMap<String, Object>();

		if (articleExamineId != null && !articleExamineId.matches(RegExpSetting.PARA_ID)) {
			dto.put("data", false);
			dto.put("msg", "articleExamineId" + StatusSetting.MSG_10050_FORMAT_IS_MISTAKE);
			dto.put("code", StatusSetting.CODE_10050);
			// dto.setData(false);
			// dto.setMsg("articleExamineId" + StatusSetting.MSG_10050_FORMAT_IS_MISTAKE);
			// dto.setCode(StatusSetting.CODE_10050);
			return dto;
		}

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", articleExamineId);
		map.put("createTime", Util.getTime());
		map.put("updateTime", Util.getTime());
		map.put("articleExamineId", articleExamineId);

		Boolean data = articleExamineAdoptMapper.create(map);
		if (!data) {
			dto.put("data", false);
			dto.put("msg", StatusSetting.MSG_10000);
			dto.put("code", StatusSetting.CODE_10000);
			// dto.setCode(StatusSetting.CODE_10000);
			// dto.setMsg(StatusSetting.MSG_10000);
			return dto;
		}
		// dto.setData(data);
		dto.put("data", data);
		dto.put("msg", StatusSetting.MSG_200);
		dto.put("code", StatusSetting.CODE_200);
		return dto;
	}

	@Override
	public Map<String, Object> deleteByArticleExamineId(String articleExamineId) {
		// TODO Auto-generated method stub
		// DataToObject<Boolean> dto = new DataToObject<Boolean>();
		Map<String, Object> dto = new HashMap<String, Object>();

		if (articleExamineId != null && !articleExamineId.matches(RegExpSetting.PARA_ID)) {
			dto.put("data", false);
			dto.put("msg", "articleExamineId" + StatusSetting.MSG_10050_FORMAT_IS_MISTAKE);
			dto.put("code", StatusSetting.CODE_10050);
			// dto.setData(false);
			// dto.setMsg("articleExamineId" + StatusSetting.MSG_10050_FORMAT_IS_MISTAKE);
			// dto.setCode(StatusSetting.CODE_10050);
			return dto;
		}

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("articleExamineId", articleExamineId);

		Boolean data = articleExamineAdoptMapper.deleteByArticleExamineId(map);
		if (!data) {
			dto.put("data", false);
			dto.put("msg", StatusSetting.MSG_10000);
			dto.put("code", StatusSetting.CODE_10000);
			// dto.setCode(StatusSetting.CODE_10000);
			// dto.setMsg(StatusSetting.MSG_10000);
			return dto;
		}
		// dto.setData(data);
		dto.put("data", false);
		dto.put("msg", StatusSetting.MSG_200);
		dto.put("code", StatusSetting.CODE_200);
		return dto;
	}

}
